package com.foodplus.www.presenter;

import com.foodplus.www.api.BaseSubscriber;
import com.foodplus.www.api.ExceptionHandle;
import com.foodplus.www.bean.login.MemberDataBean;
import com.foodplus.www.bean.login.MyAssetBean;
import com.foodplus.www.model.impl.UserDataModelImpl;
import com.foodplus.www.view.impl.MyView;

import java.util.Map;

/**
 * Created by WangZhiChao on 2016/11/2.
 */

public class UserDataPresenter {
    private MyView myView;

    public UserDataPresenter(MyView myView) {
        this.myView = myView;
    }

    public void getMemberData(Map<String, String> params) {
        new UserDataModelImpl().getMemberData(new BaseSubscriber<MemberDataBean>() {
            @Override
            public void onSuccess(MemberDataBean memberDataBean) {
                myView.onMemberDataResult(memberDataBean);
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                myView.onFail(e);
            }

            @Override
            public void onFinished() {
                myView.onFinish();
            }
        },params);
    }

    public void getMyAsset(Map<String, String> params) {
        new UserDataModelImpl().getMyAsset(new BaseSubscriber<MyAssetBean>() {
            @Override
            public void onSuccess(MyAssetBean data) {
                myView.onMyAssetResult(data);
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                myView.onFail(e);
            }

            @Override
            public void onFinished() {
                myView.onFinish();
            }
        },params);
    }

}
